package com.wy.authority.controller;

import com.wy.authority.entity.Pro_cess;
import com.wy.authority.service.ProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @Author 忘忧
 * @Date Created in 2021/1/29 17:38
 * @Description:
 */
@RestController
@RequestMapping("/pro")
public class ProcessController {
    @Autowired
    private ProcessService processService;


    @GetMapping("findall")
    public List<Pro_cess> findall(){
        List<Pro_cess> list =processService.findall();
        return list;
    }

    @PostMapping("/insert")
    public String insert(@RequestBody Pro_cess pro_cess) {
        pro_cess.setPro_time(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()));
        System.out.println(pro_cess);
        processService.insert(pro_cess);
        return "success";
    }

    //删除
    @DeleteMapping("/delete/{pro_id}")
    public void delete(@PathVariable("pro_id") Integer pro_id){
        processService.delete(pro_id);
    }
}
